<template>
  <div class="p-6 flex items-center space-x-4">
    <a-button type="primary" v-for="(app, index) in apps" :key="index" @click="openApp(app)">
      打开 {{ app.name }}
    </a-button>
  </div>
</template>

<script setup>
  // import { createWindow } from '$main/window/createWindow';
  // import { ipcRenderer } from 'electron';

  // let mainMethods = remote.getGlobal('mainMethods');
  // let newWindowInstance;
  //
  // async function handleCreateWindow() {
  //   const { browserWindowInstance } = await mainMethods.createWindow('windowEventChild', {
  //     url: '/multiple-tab',
  //   });
  //   newWindowInstance = browserWindowInstance;
  // }

  import { ref } from 'vue';
  import { ipcRenderer } from 'electron';
  import { cloneDeep } from 'lodash-es';

  const apps = ref([
    {
      name: '应用--掘金',
      loadUrl: 'https://juejin.cn/?utm_source=infinitynewtab.com',
      id: 0,
    },
    {
      name: '应用--雪梨表单',
      loadUrl: 'https://form.antdv.com',
      id: 1,
    },
  ]);

  function openApp(appInfo) {
    console.log(11, appInfo);
    ipcRenderer.send('sendMain__workbenchApplicationWindow_sendAppInfo', cloneDeep(appInfo));
  }
</script>
